package com.leyou.goods.controller;


import com.leyou.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * *
 * Created by IntelliJ IDEA.
 * Author: caoLei
 * Date: 2018/10/31
 * Time: 21:58
 * *
 */
@Controller
@RequestMapping("item")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private GoodsHtmlService goodsHtmlService;


    @GetMapping("{spuId}.html")
    public String toTemPage(Model model, @PathVariable("spuId") Long spuId) {
        Map<String, Object> map = this.goodsService.loadModel(spuId);
        model.addAllAttributes(map);
        this.goodsHtmlService.asyncExcute(spuId);
        //返回的是item.html的名字
        return "item";
    }
}
